package br.com.gbvbahia.mybooks.dao;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import br.com.gbvbahia.commons.dao.InterfaceDAO;
import br.com.gbvbahia.mybooks.dao.contract.DB;
import br.com.gbvbahia.mybooks.modelos.RemovidoVO;

public class RemovidoDAO extends InterfaceDAO<RemovidoVO, String> {

	public static final String REMOVIDOS_TABLE_NAME = "removidos";
	public static final String[] columns = { "idLivroRemovido", "dataRemocao" };

	@Override
	protected String getColumnIdName() {
		return columns[0];
	}

	public RemovidoDAO(Context ctx) {
		super(new DB(ctx));
	}

	@Override
	protected String getTableName() {
		return REMOVIDOS_TABLE_NAME;
	}

	@Override
	protected String[] getColumNames() {
		return columns;
	}

	@Override
	protected String getColumnOrderDefault() {
		return columns[1];
	}
	
	@Override
	protected RemovidoVO getFromCursor(Cursor cursor) {
		RemovidoVO toReturn = new RemovidoVO();
		toReturn.setId(cursor.getString(cursor.getColumnIndex(columns[0])));
		toReturn.setDataRemocao(Long.parseLong(cursor.getString(cursor
				.getColumnIndex(columns[1]))));
		return toReturn;
	}
	
	@Override
	protected void populateContentValues(ContentValues cv, RemovidoVO t) {
		cv.put(columns[0], t.getId());
		cv.put(columns[1], Long.toString(t.getDataRemocao()));
	}
}
